package com.unittec.drainage.sdk.root.enums;

/**
 * 日志级别定义
 */
public enum LogLevelE {

    OFF(99, "OFF"), DEBUG(1, "DEBUG"), INFO(2, "INFO"), WARING(3, "WARNIG"), ERROR(4, "ERROR");

    private final int level;
    private final String msg;

    LogLevelE(int level, String msg) {
        this.level = level;
        this.msg = msg;
    }

    public int getLevel() {
        return this.level;
    }

    public String getMsg() {
        return this.msg;
    }

    public static LogLevelE convertLevel(String msg) {
        LogLevelE[] list = values();
        for (LogLevelE logLevel : list) {
            if (logLevel.getMsg().equals(msg)) {
                return logLevel;
            }
        }
        return null;
    }

    public static LogLevelE convertLevel(int level) {
        LogLevelE[] list = values();
        for (LogLevelE logLevel : list) {
            if (logLevel.getLevel() == level) {
                return logLevel;
            }
        }
        return null;
    }
}
